import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;

public class Java_2_003 {
        public static void main(String[] args){

            ArrayList<Student> students = new ArrayList<Student>();
            addStudentName(students);
            printStudentsName(students);
            String randName=randStudentName(students);
            System.out.println("Lucky dog: "+randName);
        }

        public static void addStudentName(ArrayList<Student> students){
            Scanner sc=new Scanner(System.in);
            for(int i=0;i<3;i++){
                Student s = new Student();
                System.out.println("存储第"+(i+1)+"个名称");
                s.setId(i+1);
                System.out.println("name");
                s.setName(sc.next());
                System.out.println("age");
                s.setAge(sc.nextInt());
                students.add(s);
            }

        }
        private static void printStudentsName(ArrayList<Student> students) {
            for(int i=0;i<students.size();i++){
                Student s = students.get(i);
                System.out.println("第"+(i+1)+"个学生id："+s.getId());
                System.out.println("第"+(i+1)+"个学生age："+s.getAge());
                System.out.println("第"+(i+1)+"个学生名称："+s.getName());
            }

        }
        public static String randStudentName(ArrayList<Student> students){
            Random random = new Random();
            int index=random.nextInt(students.size());
            Student s = students.get(index);
            return s.getName();
        }


}
//改抽学生
